<%@ page contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ include file="/common/init.jsp"%>
<link href="<c:url value='/admin/css/custom.css'/>" rel="stylesheet" type="text/css" />
<link href="<c:url value='/admin/css/style.css'/>" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<c:url value='/resources/js/jquery-1.7.2.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resources/js/validate.js'/>"></script>
<script type="text/javascript">
$(function(){
	var bankname = $("#tdBankName").html();
	var type = true;
	$("select[name='bankName1']").each(function(){     
		if($(this).val() == bankname){
			$("input[name=bankType][value=1]").attr("checked",true);
			$("#bankName1").val(bankname);
			type = false;
			return false;
		}
	});
	if(type){
		$("input[name=bankType][value=2]").attr("checked",true);
		$("#bankName2").val(bankname);
	}
	//级联
   /*  $("#bankCountry").change(function(){
   	 var bankCountry = $("#bankCountry").val();
   	 var url = "${ctx}/getprovince.action";
   	 $.ajax({
			type:'POST',
			url:url,
			data: "countryId="+bankCountry,
			dataType:"html",
			success: function(data,status){
				if($.trim(data)!=''){
					$("#bankProvince").html(data);
				}
			},
			error: function(data,status,e){
				alert(e.name);
			}
		});
    }); */
	
	
	$("#button").click(function(){
		var bankRadio = $('input:radio[name="bankType"]:checked').val();
		var checkFlg = true;
		if(bankRadio == "2"){ //自定义银行
			checkFlg = checkFlg && validateEmpty_jquery("自定义开户行", "bankName2");
		}
		checkFlg = checkFlg && validateEmpty_jquery("国家", "bankCountry");
		checkFlg = checkFlg && validateEmpty_jquery("省/洲", "bankProvince");
		checkFlg = checkFlg && validateEmpty_jquery("分支行", "subBranch");
		checkFlg = checkFlg && validateEmpty_jquery("银行户名", "bankUser");
		checkFlg = checkFlg && validateEmpty_jquery("银行账号", "bankCard");
		if ( !checkFlg ) return false;
	    if (checkFlg) {
	    	$("#button").val("提交中");
			$("#button").attr("disabled","disabled");
	    	var data = $("#bankForm").serialize();
			jQuery.ajax({
				url: "updatebank.action",
				type: "post",
				dataType:"html",
				data:data,
				async:false,
				success: function(jsondata){
					alert(jsondata);
					self.location.href = "${ctx}/admin/userlist.action";
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
			    }
			});
	    }
	});
});

</script>
<style type="text/css">
<!--
body {
	background: #ffffff;
	margin-top:10px;
	margin-left:5px;
	margin-right:5px;
}
-->
</style>
<body>
<div class="EpmsSubTitle"><p><b>银行信息列表</b></p>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="EpmsTable">
	<tr>
		<td class=EpmsTdTitle><b>会员ID</b></td>
		<td class="EpmsTdTitle"><b>国家</b></td>
		<td class=EpmsTdTitle><b>省/洲</b></td>
		<td class="EpmsTdTitle"><b>开户银行</b></td>
		<td class=EpmsTdTitle><b>分支行</b></td>
		<td class="EpmsTdTitle"><b>银行户名</b></td>
		<td class=EpmsTdTitle><b>银行账号</b></td>
	</tr>
	<tr>
		<td class=EpmsTdNoColor>${userBank.userId}</td>
		<td class="EpmsTdNoColor">${userBank.bankCountry}</td>
		<td class="EpmsTdNoColor">${userBank.bankProvince}</td>
		<td class="EpmsTdNoColor" id="tdBankName">${userBank.bankName}</td>
		<td class="EpmsTdNoColor">${userBank.subBranch }</td>
		<td class="EpmsTdNoColor">
		${userBank.bankUser}
		<%-- ${fn:substring(userBank.bankUser,0,1)}** --%>
		</td>
		<td class="EpmsTdNoColor">${userBank.bankCard}</td>
	</tr>
</table>


<div class="EpmsSubTitle"><p><b>修改会员银行账户</b></p>
</div>
<form action="" method="post" id="bankForm"> 
<input type="hidden" id="account" name="account" value="${account}">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="EpmsTable">
	<tr>
		<td class=EpmsTdTitle><b>开户银行</b></td>
		<td class="EpmsTdNoColor">
			<input name="bankType" type="radio" value="1"/> 
			<select	name="bankName1" style="width: 20%" id="bankName1">
				<c:forEach var="bank" items="${bankList}">
					<option value="${bank.name}">${bank.name }</option>
				</c:forEach>
			</select> 
			<input name="bankType" type="radio" value="2" /> 
			自定义：<input name="bankName2" type="text" size="16" value="" id="bankName2"/>
		</td>
	</tr>
	<tr>
		<td class=EpmsTdTitle>国家</td>
		<td class="EpmsTdNoColor">
			<select name="userBank.bankCountry" id="bankCountry" style="width: 20%">
				<option value="">--请选择国家--</option>
				<c:forEach var="loc" items="${listCountry}">
					<option value="${loc.id.f3}" <c:if test="${userBank.bankCountry eq loc.id.f3}">selected</c:if>>${loc.id.f3 }</option>
				</c:forEach>
			</select>
		</td>
	</tr>
	<tr>
		<td class=EpmsTdTitle>省/洲</td>
		<td class="EpmsTdNoColor">
		<input name="userBank.bankProvince" id="bankProvince" value="${userBank.bankProvince}"/>
			<!-- <select name="userBank.bankProvince" id="bankProvince" style="width: 20%">
				<option value="">--请选择省市--</option>
			</select> -->
		</td>
	</tr>
	<tr>
		<td class=EpmsTdTitle>分支行</td>
		<td class="EpmsTdNoColor">
			<input name="userBank.subBranch" type="text" size="30" id="subBranch" value="${userBank.subBranch}"/>
		</td>
	</tr>
	<tr>
		<td class=EpmsTdTitle>银行户名</td>
		<td class="EpmsTdNoColor">
		<%-- ${fn:substring(userBank.bankUser,0,1)}** --%>
			<input name="userBank.bankUser" type="inputInput" size="30" id="bankUser" value="${userBank.bankUser}"/>
		</td>
	</tr>
	<tr>
		<td class=EpmsTdTitle>银行账户</td>
		<td class="EpmsTdNoColor">
			<input name="userBank.bankCard" type="inputInput" size="30" id="bankCard" value="${userBank.bankCard}"/>
		</td>
	</tr>
	<tr>
		<td colspan="2" align="center">
			<input type="button" name="button" id="button" value="确定" class="inputSubmit" />
		</td>
	</tr>
</table>
</form>
</body>